﻿@using Abc.Core;
@using Abc.Core.Entities;


@{
	ViewData["Title"] = "全球化和本地化 翻译";
}
<div class="layui-row layui-col-space10">
	<div class="layui-card" id="headsearch_LocalizationTranslation">
		<div class="layui-card-body" style="padding: 0px;">
			<form class="layui-form" action="javascript:;" id="queryform_LocalizationTranslation">

				<div class="layui-inline">
					<label class="layui-form-mid">关键词</label>
					<div class="layui-input-inline" style="width: 300px;">
						<input type="text" id="KeyWords" name="KeyWords" placeholder="输入关键词模糊查询" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-mid">创建日期</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="StartDate" id="StartDate_LocalizationTranslation" placeholder="开始日期">
					</div>
					<div class="layui-form-mid">-</div>
					<div class="layui-input-inline">
						<input class="layui-input" name="EndDate" id="EndDate_LocalizationTranslation" placeholder="结束日期">
					</div>
				</div>
				<div class="layui-inline">
					<div id="search_LocalizationTranslation" class="layui-btn submitbtn" lay-submit lay-filter="search_LocalizationTranslation"> <i class="layui-icon layui-icon-search"></i>查找</div>
					<button id="reset_LocalizationTranslation" type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-refresh">重置</i></button>
				</div>
			</form>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 0px;">
			<table id="listData_LocalizationTranslation" class="layui-hide" lay-filter="listData_LocalizationTranslation"></table>
		</div>
	</div>
</div>
<script type="text/html" id="toolbar_LocalizationTranslation">
	<div class="layui-btn layui-btn-primary layui-btn-md" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</div>
	<div class="layui-btn layui-btn-danger layui-btn-md" lay-event="batchRemove"><i class="layui-icon layui-icon-delete"></i>删除</div>
</script>
<script type="text/html" id="tablebar_LocalizationTranslation">
	<div class="layui-btn layui-btn-sm layui-btn-primary more_{{d.Id}}"><i class="layui-icon layui-icon-triangle-d">更多</i></div>
</script>

@*自动生成开关代码*@
@* 默认假删除 *@
@*<script type="text/html" id="tpl_IsDeleted_LocalizationTranslation">
    <input type="checkbox" name="IsDeleted_LocalizationTranslation" objid="{{d.Id}}" lay-skin="switch" title="启用|禁用" lay-filter="IsDeleted_LocalizationTranslation" {{ d.IsDeleted ? 'checked' : '' }}>
    </script>*@
<script type="text/html" id="tpl_Type_LocalizationTranslation">
	{{# if(d.Type==1){ }}
	  <span class="layui-badge layui-bg-orange">IPV4</span>
	{{# }else { }}
	  <span class="layui-badge layui-bg-blue">IPV6</span>
	{{# } }}
</script>

@section Scripts{
	<script>
		layui.use(['table', 'form', 'jquery', 'drawer', 'dropdown', 'layer'], function () {
			let $ = layui.jquery;
			let layer = layui.layer;
			let table = layui.table;
			let form = layui.form;
			let drawer = layui.drawer;
			let dropdown = layui.dropdown;

			abc.indexInit({ reset: '#reset_LocalizationTranslation', search: '#search_LocalizationTranslation' });
			//监听头工具栏事件
			table.on('toolbar(listData_LocalizationTranslation)', function (obj) {
				if (obj.event === 'add') {
					abc.open({ title: '新增', url: '@(Url.Action("Add", "HtLocalizationTranslation", new { area = "HtAdmin" }))', area: ['100%', '98%'], end: refresh_LocalizationTranslation });
				} else if (obj.event === 'refresh') {
					refresh_LocalizationTranslation();
				} else if (obj.event === 'batchRemove') {
					var ids = abc.getSelectDataIds(table, "listData_LocalizationTranslation");
					if (ids.length === 0) {
						layer.msg("未选中数据", { icon: 3, time: 1000 });
						return false;
					}
					abc.delete({ url: "@(Url.Action("BatchDelete", "HtLocalizationTranslation", new { area = "HtAdmin" }))", data: { ids: ids }, success: function () { refresh_LocalizationTranslation() } });
				}
			});
			table.on('tool(listData_LocalizationTranslation)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
				var data = obj.data; //获得当前行数据
				var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				var tr = obj.tr; //获得当前行 tr 的DOM对象
				if (layEvent === 'delete') { //删除
				    abc.delete({url:"@(Url.Action("BatchDelete", "HtLocalizationTranslation", new { area = "HtAdmin" }))",data:{ ids: data.Id },success:function(){obj.del();refresh_LocalizationTranslation()}});
				} else if (layEvent === 'edit') { //编辑
				    edit_LocalizationTranslation(obj);
				} else if (obj.event === 'save') {
				    if (editrowids.indexOf(obj.data.Id) == -1) {
				        abc.failure("请先修改后再保存")
				    }
				    else {
				        abc.success("保存成功消息")
				    }
				}else if (obj.event === 'more') {
                    dropdown.render({
                        elem: this, // 触发事件的 DOM 对象
                        show: true, // 外部事件触发即显示
                        data: [
                            { title: '详情', id: 'edit' },
                            { title: '删除', id: 'delete' },
                        ]
                        , click: function (menudata) {

                            if (menudata.id === 'edit') {
                                edit_LocalizationTranslation(obj);
                            } if (menudata.id === 'delete') {
                               abc.delete({ url: "@(Url.Action("BatchDelete"))", data: { ids: obj.data.Id }, success: function () { refresh_LocalizationTranslation() } });
                            }

                        }
                    });
                }

			});
			//table 行双击事件
			table.on('rowDouble(listData_LocalizationTranslation)', function (obj) { edit_LocalizationTranslation(obj); });
			//table 行中的事件监听
			//编辑
			function edit_LocalizationTranslation(obj) {
				abc.open({ title: '编辑', url: '@(Url.Action("Info", "HtLocalizationTranslation", new { area = "HtAdmin" }))/' + obj.data.Id, area: ['100%', '98%'], end: refresh_LocalizationTranslation });
			}


			//Table 初始化
			//, templet: '#tpl_user'
			var cols = [
				[
					//, templet: '#tpl_IsEnable_LocalizationTranslation'
					//{ type: 'checkbox', fixed: 'left'},
					//{ type: 'numbers', fixed: 'left', rowspan: 1 },
					//{ title: '标签', 'toolbar': '#tplable', fixed: 'left', width: 100 },
					//{ title: 'ID', field: 'Id', width: 60 },


					{ title: 'ID', field: 'Id', width: 60, align: 'center' },
					{ title: '区域码', field: 'Culture', minWidth: 60, align: 'center' },
					{ title: '翻译', field: 'Translation', minWidth: 60, align: 'center' },
					{ title: '备注', field: 'Remark', minWidth: 60, align: 'center' },
					//{ title: '全球化和本地化Id', field: 'LocalizationId', minWidth: 60, align:'center' },
					{ title: '创建用户ID', field: 'CreatorUserId', minWidth: 60, align: 'center', hide: true },
					{ title: '创建用户', field: 'CreatorUserName', minWidth: 60, align: 'center', hide: true },
					{ title: '创建时间', field: 'CreationTime', width: 130, align: 'center' },
					{ title: '更新用户ID', field: 'UpdateUserId', minWidth: 60, align: 'center', hide: true },
					{ title: '更新用户', field: 'UpdateUserName', minWidth: 60, align: 'center', hide: true },
					{ title: '更新时间', field: 'UpdateTime', width: 130, align: 'center' },
					//{ title: '默认假删除', field: 'IsDeletedName', width: 60, align:'center' },// templet: '#tpl_IsDeleted_LocalizationTranslation'
					//{ title: '删除用户ID', field: 'DeletedUserId', minWidth: 60, align:'center' },
					//{ title: '删除用户', field: 'DeletedUserName', minWidth: 60, align:'center' },
					//{ title: '删除时间', field: 'DeletedTime', width: 130, align:'center',hide:true },

					{ title: '操作', fixed: 'right', width: 80, align: 'left', toolbar: '#tablebar_LocalizationTranslation' }
				]
			];
			//表格下拉菜单

			//初始化table
			abc.initTable("listData_LocalizationTranslation", cols, { title: '全球化和本地化 翻译', toolbar: '#toolbar_LocalizationTranslation' });

			//提交搜索
			form.on('submit(search_LocalizationTranslation)', function (obj) {
				abc.search('listData_LocalizationTranslation', '@(Url.Action("GetList", "HtLocalizationTranslation", new { area = "HtAdmin" }))', obj.field, { method: "post", done: tableDone_LocalizationTranslation });
				return false;
			});
			$("#search_LocalizationTranslation").click();//初始化完成后 搜索一次
			function refresh_LocalizationTranslation() {
				//table.reload("listData_LocalizationTranslation");
				$("#search_LocalizationTranslation").click();
			};
			//IsEnable 开关事件
			form.on('switch(IsEnable_LocalizationTranslation)', function (obj) {
				//console.log(this, obj, { Id: $(this).attr('objid'), isEnable: obj.elem.checked });
				abc.post({ url: '@(Url.Action("SetEnable", "HtLocalizationTranslation", new { area = "HtAdmin" }))', data: { id: $(this).attr('objid'), state: obj.elem.checked, type: 'isenable' } });
			});
		@*自动生成开关代码*@
				// 默认假删除 开关事件
		@*form.on('switch(IsDeleted_LocalizationTranslation)', function (obj) {
			//console.log(this, obj, { Id: $(this).attr('objid'), isEnable: obj.elem.checked });
			abc.post({ url: '@(Url.Action("SetEnable","HtLocalizationTranslation", new { area = "HtAdmin" }))', data: { id: $(this).attr('objid'), state:obj.elem.checked,type:'IsDeleted.ToLower())' }});
			});*@

					//事件集合
					var active = {
				example: function () {
				},
				example1: function () {
				}
			};

			//表格下拉菜单
			//tableDone_LocalizationTranslation(res, curr, count) {}
			function tableDone_LocalizationTranslation(res, curr, count) {
				
			}

			//注册layui-btn 事件
			$('.layui-btn').on('click', function () {
				var type = $(this).data('type');
				active[type] ? active[type].call(this) : '';
			});

			// 初始化日期选择
			//abc.initDate('StartDate_LocalizationTranslation,EndDate_LocalizationTranslation');


		});
	</script>
}


